package crawler.client.core;

import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import crawler.client.core.handle.InfoHandle;
import crawler.protocol.CrawlerClientProtocol;
import crawler.protocol.UpdateProtocol;
import crawler.protocol.client.ClientInfoProtocol;

@Service
public class RequestServer {
	
	private static Logger log = LoggerFactory.getLogger(RequestServer.class);
	
	@Autowired
	private InfoHandle infoHandle;
	
	
	public RequestServer(){
		
	}
	
	
	public JSONObject getTask(){
		CrawlerClientProtocol crawlerClientProtocol = new CrawlerClientProtocol();
		ClientInfoProtocol client = new ClientInfoProtocol();
		List<UpdateProtocol> update = new ArrayList<UpdateProtocol>();
		
		infoHandle.collectClientInfo(client,false);
		
		crawlerClientProtocol.setClient(client);
		crawlerClientProtocol.setUpdate(update);
		
//		try {
//			HttpClientResponse responseBean = HttpClientUtil.post(ServerInfo.SERVER_URL_TASK, JSON.toJSONString(crawlerClientProtocol,SerializerFeature.WRITE_MAP_NULL_FEATURES));
//		} catch (IOException e) {
//			log.error("getTask Error",e);
//			e.printStackTrace();
//		}
		
		
		return null;
	}
	
	public JSONObject reportInfo(){
		return null;
	}
	
	public JSONObject reportData(){
		return null;
	}
	
	public JSONObject download(){
		return null;
	}
	
	public JSONObject getAccount(){
		return null;
	}
	
	public JSONObject getProxy(){
		return null;
	}
	
	public static void main(String[] args) {
		RequestServer requestServer = new RequestServer();
		requestServer.getTask();
	}
}
